import request from '../utils/requist'

export const req_swiperList = () => {
    return request.get('/slider/getSliders')
}

export const req_category_1_list_list = () => {
    return request.get('/course/category/getFirstCategorys')
}

export const req_category_2_list_list = (categoryId) => {
    return request.get('/course/category/getSecondCategorys?categoryId=' + categoryId)
}

export const req_CourseList = (data) => {
    return request.post('/course/search', data)
}

export const req_CourseDetaile = (courseId) => {
    return request.get('/course/getDetail', {
        params: {
            courseId
        }
    })
}

// 请求下载文件
export const req_downloadFile = (params) => {
    return request.get('/course/downloadAttachment', {
        params,
        responseType: 'blob'
    })
}
// 询问是否有权限 下载

export const req_checkAuth = (params) => {
    return request.get('/course/checkAuth', {
        params
    })
}
// 请求播放
export const req_DetailePlay = (params) => {
    return request.get('/player/play', {
        params
    })
}

// 登录
export const req_login = (data) => {
    return request.post('/u/loginByJson', data)
}

export const req_Out_login = () => {
    return request.get('/u/logout')
}

export const req_CreateToken = () => {
    return request.get('/token/createToken')
}

// 获取用户信息 
export const req_UserInfo = (token) => {
    return request.get('/member/getInfo', {
        params: {
            token
        }
    })
}


// 视频播放-------------------------------------------------------------------------------------------------------------------------
// 实时更新播放记录时长
export const req_upDatePlayHistory = (data) => {
    return request.post('/course/history/recordHistory', data)
}

export const req_GetLastPlayHistory = (params) => {
    return request.get('/course/history/getLastHistoryByChapterId', {
        params
    })
}


// 购物车-----------------0-------------------------------------------------------------------------------------------------------------------
export const req_shopCarList = () => {
    return request.get('/shopcar/getShopCarList')
}
// 删除购物车数据
export const req_delShopCarItem = (token, params) => {
    return request.get('/shopcar/deleteShopCar', {
        params,
        headers: {
            token
        }
    })
}

// 添加购物车数据
export const req_AddShopCarItem = (token, data) => {
    return request.post('/shopcar/addShopCar', data, {
        headers: {
            token
        }
    })
}

// 去结算
export const req_submitShopCar = (data) => {
    return request.post('/order/settlement', data)
}


// 付钱
export const req_PayByAlipayment = (data) => {
    return request.post('/pay/alipay/createOrder', data)
}

// 查询是否已经支付
export const req_PayStatus = (orderNumber) => {
    return request.get('/pay/alipay/queryOrder', {
        params: {
            orderNumber
        }
    })
}